package org.dpes.compare;

import org.dpes.compare.compareManager.SimpleTaskManagerImpl;
import org.dpes.compare.compareManager.Task;
import org.dpes.compare.compareManager.TaskManager;

public class CompareManager extends Thread {
	
	private TaskManager taskManager;
	
	private boolean work = true;
	
	public CompareManager() {
		start();
	}
	
	public synchronized long addTask(Task task) {
		return getTaskManager().add(task);
	}
	
	public synchronized void stopWorking() {
		work = false;
	}
	
	@Override
	public void run() {
		while (work) {
			work();
		}
	}

	private void work() {
		/*
		 * to implement...
		 */
	}

	private TaskManager getTaskManager() {
		if (taskManager == null)
			taskManager = new SimpleTaskManagerImpl();
		return taskManager;
	}
}
